package com.example.spareparts.repository;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.*;
import java.util.List;
import com.example.spareparts.entity.InventoryAdjustments;


@Mapper
public interface InventoryAdjustmentsRepository {
    @Select("SELECT * FROM InventoryAdjustments")
    List<InventoryAdjustments> findAllInventoryAdjustments();

    @Insert("INSERT INTO InventoryAdjustments (spare_part_id, difference, adjustment_date) VALUES (#{sparepartid}, #{difference}, #{adjustmentDate})")
    @Options(useGeneratedKeys = true, keyProperty = "adjustmentid")
    void insertInventoryAdjustments(InventoryAdjustments inventoryAdjustments);
    @Update("UPDATE InventoryAdjustments SET adjustment_id= #{adjustmentid}, spare_part_id= #{sparepartid}, difference= #{difference}, adjustment_date= #{adjustmentDate} WHERE adjustment_id= #{adjustmentid}")
    void updateInventoryAdjustments(InventoryAdjustments inventoryAdjustments);

    @Delete("DELETE FROM InventoryAdjustments WHERE adjustment_id= #{adjustmentid}")
    void deleteInventoryAdjustments(Long adjustmentid);

    @Select("SELECT * FROM InventoryAdjustments WHERE adjustment_id= #{adjustmentid}")
    InventoryAdjustments findInventoryAdjustmentsById(Long adjustmentid);

    @Select("SELECT * FROM InventoryAdjustments WHERE spare_part_id= #{sparepartid}")
    List<InventoryAdjustments> findInventoryAdjustmentsBySparePartId(Long sparepartid);
}